package xyz.thoughtset.viewer.apis.client.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HtmlApi {
    @RequestMapping({"/","/index"})
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response)throws Exception{
        ModelAndView mv =  new ModelAndView();
        mv.setViewName("/html/index.html");
        noHtmlCache(response);
        return mv;
    }

    private void noHtmlCache(HttpServletResponse response){
        response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-cache, no-store");
        response.setHeader("Pragma", "no-cache");
    }

}
